﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NielsDerdaele.HttpSocket.Windows;
using System.Threading;
using System.IO;

namespace NielsDerdaele.HttpSocket.Example.Server {
    public class ChatServer {
        private const string HOSTNAME = "*";
        private const int PORT = 1330;
        private List<ChatClient> clients = new List<ChatClient>();

        private HttpSocketListener httpSocketListener = new HttpSocketListener();

        public ChatServer() {

        }

        public void Start() {
            //TODO: started property
            httpSocketListener.Start(HOSTNAME, PORT);
            httpSocketListener.NewHttpServerClientSocket += new EventHandler<EventArgs<HttpServerClientSocket>>(httpSocketListener_NewHttpServerClientSocket);
        }
        private void httpSocketListener_NewHttpServerClientSocket(object sender, EventArgs<HttpServerClientSocket> e) {            
            var client = new ChatClient(new HttpServerClientStream(e.Value));
            clients.Add(client);            
        }        
    }
}
